import { Module } from '@nestjs/common';
import { RedisModule } from '@nestjs-modules/ioredis';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import {
  getDataBase
} from './config/database.config';
import { TypeOrmModule  } from '@nestjs/typeorm';
import { CatsModule } from './entity/cats/cats.module';
import { VideoModule } from './entity/video/video.module';
import { LikeVideoModule } from './entity/likeVideo/likeVideo.module';
import { WxUserModule } from './entity/wxUser/wxUser.module';
import { InternetCelebrityModule } from './entity/internetCelebrity/internetCelebrity.module';
import { ShieLDModule } from './entity/shield/shield.module';
import { SettingModule } from './entity/setting/setting.module';
import { AnswerModule } from './entity/answer/answer.module';
import { AnswerTemplateModule } from './entity/answerTemplate/answerTemplate.module';
import { ProfitModule } from './entity/profit/profit.module';
import { WalletFlowModule } from './entity/walletFlow/walletFlow.module';
import { TreasuryModule } from './entity/treasury/treasury.module';
import { UserModule } from './entity/user/user.module';
import { PlatformModule } from './entity/platform/platform.module';
import { AnswerReportErrorsModule } from './entity/answerReportErrors/answerReportErrors.module';
import { InternetCelebrityGroupModule } from './entity/internetCelebrityGroup/internetCelebrityGroup.module';
import { MediaCheckModule } from './entity/mediaCheck/mediaCheck.module';
import { WxUserOpenIdModule } from './entity/wxUserOpenId/wxUserOpenId.module';
import { TagsModule } from './entity/tags/tags.module';
import { VideoTagModule } from './entity/videoTag/videoTag.module';
import { WatchRecordModule } from './entity/watchRecord/watchRecord.module';
import { NoticesModule } from './entity/notices/notices.module';
import { UserSettingModule } from './entity/userSetting/userSetting.module';
import { ConcernModule } from './entity/concern/concern.module';
import { RewardModule } from './entity/reward/reward.module';
import { Video } from './entity/video/video.entity';
import { InternetCelebrityGroup } from './entity/internetCelebrityGroup/internetCelebrityGroup.entity';
import { WxUser } from './entity/wxUser/wxUser.entity';
import { QuestionsModule } from './entity/questions/questions.module'
import { VideoLibraryModule } from './entity/videoLibrary/videoLibrary.module';
import { RejectReasonModule } from './entity/rejectReason/rejectReason.module';
import { InternetCelebrityGroupRelaIcInfoModule } from './entity/internetCelebrityGroupRelaIcInfo/internetCelebrityGroupRelaIcInfo.module';
import { InternetCelebrityGroupCheckModule } from './entity/internetCelebrityGroupCheck/internetCelebrityGroupCheck.module';
import { redisConfig } from './config/redis.config';
import { WSModule } from './entity/ws/ws.module';
import { RedisCacheModule } from './entity/redisCache/redisCache.module';
import { RateLimiterModule } from './entity/rateLimiter/rateLimiter.module';
import { RechargeFlowModule } from './entity/rechargeFlow/rechargeFlow.module';

@Module({
  imports: [
    TypeOrmModule.forRoot(getDataBase()),
    CatsModule,
    VideoModule,
    LikeVideoModule,
    WxUserModule,
    InternetCelebrityModule,
    ShieLDModule,
    SettingModule,
    AnswerModule,
    AnswerTemplateModule,
    ProfitModule,
    WalletFlowModule,
    TreasuryModule,
    UserModule,
    PlatformModule,
    AnswerReportErrorsModule,
    InternetCelebrityGroupModule,
    MediaCheckModule,
    WxUserOpenIdModule,
    TagsModule,
    VideoTagModule,
    WatchRecordModule,
    NoticesModule,
    UserSettingModule,
    ConcernModule,
    RewardModule,
    QuestionsModule,
    VideoLibraryModule,
    RejectReasonModule,
    InternetCelebrityGroupRelaIcInfoModule,
    InternetCelebrityGroupCheckModule,
    TypeOrmModule.forFeature([Video, InternetCelebrityGroup, WxUser]),
    RedisModule.forRoot({
      type: "single",
      url: `redis://${redisConfig.host}:${redisConfig.port}`,
      options:{
        db: Number(!process.env.ServerApp ? 2 : process.env.redisdb),
        password: redisConfig.password
      }
    }),
    WSModule,
    RedisCacheModule,
    RateLimiterModule,
    RechargeFlowModule
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
